package net.pulseproject.router.modules.logic;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import javax.sound.midi.ShortMessage;

import net.pulseproject.commons.util.MidiUtil;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SimpleListenerCollector implements SimpleListener {
	
	private static final Log LOG = LogFactory.getLog(SimpleListenerCollector.class);
	
	private final List<ShortMessage> collectedMessages = new LinkedList<ShortMessage>();
	
	@Override
	public final void onSimpleListened(final ShortMessage message) {
		LOG.trace("onSimpleListened(message=" + MidiUtil.toString(message) + ")");
		this.collectedMessages.add(message);
	}

	public final List<ShortMessage> getCollectedMessages() {
		return Collections.unmodifiableList(this.collectedMessages);
	}
	
}
